﻿/**
 *	(C) 2014 Yuanjj
 *
 * 	define ui protocal
 *
 *	histroy
 * 		2014-08-08	Yuanjj		-	create
 */

#ifndef _UI_PROTOCAL_H_
#define _UI_PROTOCAL_H_

#include "typedef.h"
#include "protocal.h"

enum
{
    UI_USER_LOGIN	= 0x80,					// user login

    UI_HOST			= 0x84,					// update host

    UI_TUNNEL_TYPE	= 0x88,					// update tunnel type
    UI_TUNNEL,								// update tunnel

    UI_DEV_TYPE		= 0x90,					// update device type
    UI_DEVICE,								// update device

    UI_PROTOCAL		= 0x98,					// update protocal

    UI_ALARM		= 0xA0,					// update alarm

    UI_EVENT_TYPE	= 0xA8,					// update event type
    UI_EVENT,								// update event

    UI_SCENE		= 0xB0,					// update scene
    UI_SCENE_NEW,							// new scene

    UI_FRAME		= 0xB8,					// create main frame

    // not exit 0xC0
};

/**
 * 	description:	user login
 *	second:			UI_USER_LOGIN(0x80)
 * 	body:			ui_user_login
 */
typedef struct _ui_user_login
{
    pem_s8_t		account[USER_ACCOUNT_LEN];
    pem_s32_t		privilege;
    pem_s32_t		status;
} ui_user_login;

/**
 * 	description:	update host
 *	second:			UI_HOST(0x84)
 * 	body:			ui_host
 */
typedef struct _ui_host
{
    pem_u32_t		serial;
    pem_s8_t		host[HOST_ID_LEN];
    pem_s8_t		name[HOST_NAME_LEN];
    pem_s8_t		ip[HOST_IP_LEN];
    pem_u16_t		port;
    pem_s32_t		status;				// 0:delete, 1:add, 2:modify, 3:connect, 4:disconnect
} ui_host;

/**
 * 	description:	update ui tunnel type
 *	second:			UI_TUNNEL_TYPE(0x88)
 * 	body:			ui_tunnel_type
 */
typedef struct _ui_tunnel_type
{
    pem_u32_t		serial;
    pem_s8_t		type[TUNNEL_TYPE_LEN];
} ui_tunnel_type;

/**
 * 	description:	update ui tunnel
 *	second:			UI_TUNNEL(0x89)
 * 	body:			ui_tunnel
 */
typedef struct _ui_tunnel
{
    pem_u32_t		serial;
    pem_s8_t		host[HOST_ID_LEN];
    pem_s8_t		number[TUNNEL_NUMBER_LEN];
    pem_s8_t		name[TUNNEL_NAME_LEN];
    pem_s8_t		type[TUNNEL_TYPE_LEN];
    pem_s8_t		remark[REMARK_LEN];
    pem_s32_t		used;
} ui_tunnel;

/**
 * 	description:	update ui device type
 *	second:			UI_DEV_TYPE(0x90)
 * 	body:			ui_dev_type
 */
typedef struct _ui_dev_type
{
    pem_u32_t		serial;
    pem_s8_t		type[DEV_TYPE_LEN];
    pem_s8_t		name[DEV_NAME_LEN];
    pem_s8_t		probe[DEV_PROBE_LEN];
    pem_s8_t		img[DEV_IMG_LEN];
    pem_s8_t		append[DEV_APPEND_LEN];
} ui_dev_type;

/**
 * 	description:	update ui device
 *	second:			UI_DEVICE(0x91)
 * 	body:			ui_device
 */
typedef struct _ui_device
{
    pem_s8_t		host[HOST_ID_LEN];
    pem_s8_t		dev_id[DEV_ID_LEN];
    pem_s8_t		dev_type[DEV_TYPE_LEN];
    pem_s8_t		dev_name[DEV_NAME_LEN];
    pem_s8_t		dev_pos[DEV_POS_LEN];
    pem_s8_t		add_time[DATETIME_LEN];
    pem_s8_t		machine[DEV_MACHINE_LEN];
    pem_s8_t		tunnel_num[TUNNEL_NUMBER_LEN];
    pem_s8_t		pto_name[PTO_NAME_LEN];
    pem_s8_t		value[DEV_VALUE_LEN];
    pem_s32_t		x;
    pem_s32_t		y;
    pem_s32_t		setup;
} ui_device;

/**
 * 	description:	update ui protocal
 *	second:			UI_PROTOCAL(0x98)
 * 	body:			ui_protocal
 */
typedef struct _ui_protocal
{
    pem_u32_t		serial;
    pem_s8_t		pto_name[PTO_NAME_LEN];
    pem_s8_t		pto_file[PTO_FILE_LEN];
    pem_s8_t		tunnel_type[TUNNEL_TYPE_LEN];
    pem_s8_t		dev_type[DEV_TYPE_LEN];
    pem_s8_t		remark[REMARK_LEN];
    pem_s32_t		used;
} ui_protocal;

/**
 * 	description:	update ui alarm
 *	second:			UI_ALARM(0xA0)
 * 	body:			ui_alarm
 */
typedef struct _ui_alarm
{
    pem_u32_t		serial;
    pem_s8_t		host[HOST_ID_LEN];
    pem_s8_t		dev_id[DEV_ID_LEN];
    pem_s8_t		cmp_start[ALARM_CMP_LEN];
    pem_s32_t		alm_start;
    pem_s8_t		cmp_stop[ALARM_CMP_LEN];
    pem_s32_t		alm_stop;
    pem_s8_t		link_host[HOST_ID_LEN];
    pem_s8_t		link_dev[DEV_ID_LEN];
} ui_alarm;

/**
 * 	description:	update ui event type
 *	second:			UI_EVENT_TYPE(0xA8)
 * 	body:			ui_event_type
 */
typedef struct _ui_event_type
{
    pem_u32_t		serial;
    pem_s8_t		type[EVENT_TYPE_LEN];
} ui_event_type;

/**
 * 	description:	update ui event
 *	second:			UI_EVENT(0xA9)
 * 	body:			ui_event
 */
typedef struct _ui_event
{
    pem_u32_t		serial;
    pem_s8_t		type[EVENT_TYPE_LEN];
    pem_s8_t		datetime[DATETIME_LEN];
    pem_s8_t		user[USER_ACCOUNT_LEN];
    pem_s8_t		descript[EVENT_DESCRIPT_LEN];
} ui_event;

/**
 * 	description:	update ui scene
 *	second:			UI_SCENE(0xB0)
 * 	body:			ui_scene
 */
typedef struct _ui_scene
{
    pem_s8_t		img[SCENE_IMG_LEN];
} ui_scene;

/**
 * 	description:	new ui scene
 *	second:			UI_SCENE_NEW(0xB1)
 * 	body:			ui_scene_reload
 */
typedef struct _ui_scene_new
{
    pem_s8_t		img[SCENE_IMG_LEN];
} ui_scene_new;

/**
 * 	description:	update ui frame
 *	second:			UI_FRAME(0xB8)
 * 	body:			ui_frame
 */
typedef struct _ui_frame
{
} ui_frame;

#endif // _UI_PROTOCAL_H_
